#ifndef __LOGGER_HPP__
#define __LOGGER_HPP__

#include <iostream>
#include <ctime>
#include <cstring>

#define DBG_LEVEL 0
#define INF_LEVEL 1
#define ERR_LEVEL 2

#define DEFAULT_LEVEL DBG_LEVEL

#define LOG(str,level,format,...) \
{\
    if(level>=DEFAULT_LEVEL)\
    {\
        time_t tm=time(nullptr);\
    struct tm* ptm=localtime(&tm);\
    char buffer[32];\
    bzero(buffer,sizeof(buffer));\
    strftime(buffer,sizeof(buffer)-1,"%H:%M:%S",ptm);\
    fprintf(stdout,"[%s][%s][%s:%d]\t" format "\n",str,buffer,__FILE__,__LINE__,##__VA_ARGS__);\
    }\
}
    

#define DLOG(format,...) LOG("DBG",DBG_LEVEL,format,##__VA_ARGS__)
#define ILOG(format,...) LOG("INF",INF_LEVEL,format,##__VA_ARGS__)
#define ELOG(format,...) LOG("ERR",ERR_LEVEL,format,##__VA_ARGS__)

#endif